<?php
class PackageSlotProvider
{
	protected $package;
	public function __construct(&$package)
	{ 
		$this->package=$package;
	}
	public static function getInstance(&$pckg)
	{
		return new PackageSlotProvider($pckg);
	}	
	public function init()
	{
	}
	
	function setPackage($package)
	{
		return $this->package=$package;
	}
	
	public function render($slotid)
	{
		$ref=$this->package->ownContent_travelpackage;
		$content=null;
		foreach ($ref as $id =>$entity)
		{
			if($entity->fitsinto == $slotid)
			{
				$content=$entity->content;
			}
		}
		if(empty($content))
			return null;
		else
		 return '<div>'.$content->body.'</div>'	;
	}
	
	public function __get($key){
          $content=$this->render($key);
		  return empty($content)? '':$content;
    }
}